package com.dwxt.community.controller;

import com.dwxt.common.base.*;
import com.dwxt.community.service.*;
import org.apache.commons.lang.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/cms/broadcast")
public class BroadcastController {
    @Autowired
    private BroadcastService broadcastService;

    /**
     * showdoc
     * @catalog 社区/直播
     * @title 栏目列表  or 搜索
     * @method  get
     * @description  栏目列表  or 搜索
     * @param type 非必须 String 栏目类型ID
     * @param name 非必须 String 搜索 关键词
     * @url /cms/broadcast/getIncludeChild
     * @return {"status":200,"msg":"SUCCESS","data":{"total":4,"list":[{"id":"158564638123180","name":"奥特曼","priority":20,"description":"新的风暴已经出现\n怎么能够停止不前","type":"158564821672458","createTime":"2020-03-3109:19:41","updateTime":"2020-03-3109:19:41","cover":"栏目2","areaCode":"2100","use":0,"columnType":{"id":"158564821672458","name":"电视","createTime":1585677004000,"updateTime":1585677005000,"description":"电视"}}],"pageNum":1,"pageSize":10,"size":4,"startRow":1,"endRow":4,"pages":1,"prePage":0,"nextPage":0,"isFirstPage":true,"isLastPage":true,"hasPreviousPage":false,"hasNextPage":false,"navigatePages":8,"navigatepageNums":[1],"navigateFirstPage":1,"navigateLastPage":1}}
     */
    @GetMapping("/get")
    public BaseResult get(@RequestParam(defaultValue = "1") Integer pageNum,
                          @RequestParam(defaultValue = "10") Integer pageSize,
                          String type,
                          String name) {
        return broadcastService.getDesk(pageNum, pageSize, type, name);
    }
    /**
     * showdoc
     * @catalog 社区/直播
     * @title 获取热门栏目
     * @method  get
     * @description  获取热门栏目
     * @url /cms/broadcast/hot
     * @return {"status":200,"msg":"SUCCESS","data":[{"id":"123","name":"猫和老鼠","priority":10,"description":"不分男女老少的神片【猫和老鼠】","type":"158564821672458","createTime":1585669163000,"updateTime":1585669165000,"cover":"栏目1","areaCode":"2200","use":0,"delete":null,"hot":1},{"id":"158564641477222","name":"重庆嘉华大桥车流直播","priority":3,"description":"重庆嘉华大桥车流直播","type":"158564818887714","createTime":1585646415000,"updateTime":1585646415000,"cover":"栏目3","areaCode":"3400","use":0,"delete":null,"hot":1}]}
     */
    @RequestMapping("/hot")
    public BaseResult getHot(){
        return broadcastService.getHot();
    }
    /**
     * showdoc
     * @catalog 社区/直播
     * @title 获取热门视频
     * @method  get
     * @description  获取热门视频
     * @url /cms/broadcast/hotVideo
     * @return {"status":200,"msg":"SUCCESS","data":[{"id":"123","name":"猫和老鼠","priority":10,"description":"不分男女老少的神片【猫和老鼠】","type":"158564821672458","createTime":1585669163000,"updateTime":1585669165000,"cover":"栏目1","areaCode":"2200","use":0,"delete":null,"hot":1},{"id":"158564641477222","name":"重庆嘉华大桥车流直播","priority":3,"description":"重庆嘉华大桥车流直播","type":"158564818887714","createTime":1585646415000,"updateTime":1585646415000,"cover":"栏目3","areaCode":"3400","use":0,"delete":null,"hot":1}]}
     */
    @RequestMapping("/hotVideo")
    public BaseResult getHotVideo(){
        return broadcastService.getHotVideo();
    }

    /**
     * showdoc
     * @catalog 社区/直播
     * @title 直播栏目列表  包含栏目下的视频
     * @method  get
     * @param type 必须 String 栏目类型
     * @description  直播栏目列表  包含 栏目下的视频
     * @url /cms/broadcast/getIncludeChild
     * @return {"status":200,"msg":"SUCCESS","data":{"total":8,"list":[{"id":"123","name":"猫和老鼠","priority":10,"description":"不分男女老少的神片【猫和老鼠】","type":"158564821672458","createTime":"2020-03-3115:39:23","updateTime":"2020-03-3115:39:25","cover":"栏目1","areaCode":"2200","use":0,"broadcasts":[{"id":"158564638127323","title":"猫和老鼠最后一集","priority":0,"description":"testInsertBroastcast","type":null,"path":"http://125.62.47.82/upload/xxx.mp4","cover":"http://192.168.1.6:9091/upload/20200407201514327.jpg","createTime":"2020-03-3109:19:41","updateTime":"2020-03-3109:19:41","columeId":"123"}],"pageNum":1,"pageSize":10,"size":4,"startRow":1,"endRow":4,"pages":1,"prePage":0,"nextPage":0,"isFirstPage":true,"isLastPage":true,"hasPreviousPage":false,"hasNextPage":false,"navigatePages":8,"navigatepageNums":[1],"navigateFirstPage":1,"navigateLastPage":1}}
     */
    @GetMapping("/getIncludeChild")
    public BaseResult getIncludeChild(@RequestParam(defaultValue = "1") Integer pageNum,
                                      @RequestParam(defaultValue = "10") Integer pageSize,
                                      String type) {
        return broadcastService.getIncludeChild(pageNum, pageSize, type);
    }

    /**
     * showdoc
     * @catalog 社区/直播
     * @title 通过栏目ID获取直播列表
     * @method  get
     * @param id 必须 String 栏目ID
     * @description  通过栏目ID获取直播列表
     * @url /cms/broadcast/broadcastByColumnId
     * @return {"status":200,"msg":"SUCCESS","data":{"total":2,"list":[{"id":"158626193389521","title":"奥特曼第一集","priority":null,"description":null,"type":null,"path":"http://125.62.47.82/upload/xxx.mp4","cover":"http://192.168.1.6:9091/upload/20200407201851418.jpg","createTime":"2020-04-0712:18:54","updateTime":"2020-04-0712:18:54","columeId":"158564638123180"}],"pageNum":1,"pageSize":10,"size":2,"startRow":1,"endRow":2,"pages":1,"prePage":0,"nextPage":0,"isFirstPage":true,"isLastPage":true,"hasPreviousPage":false,"hasNextPage":false,"navigatePages":8,"navigatepageNums":[1],"navigateFirstPage":1,"navigateLastPage":1}}
     */
    @GetMapping("/broadcastByColumnId")
    public BaseResult broadcastByColumnId(@RequestParam(defaultValue = "1") Integer pageNum,
                                      @RequestParam(defaultValue = "10") Integer pageSize,
                                      String id) {
        if (StringUtils.isBlank(id)){
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return broadcastService.broadcastByColumnId(pageNum, pageSize, id);
    }


    /**
     * showdoc
     * @catalog 社区/直播
     * @title 通过直播ID获取直播详情并且包含相关视频
     * @method  get
     * @param id 必须 String 栏目下直播的ID
     * @description  通过直播ID获取直播详情并且包含相关视频
     * @url /cms/broadcast/broadcastDetailAndCorrelation
     * @return {"status":200,"msg":"SUCCESS","data":{"broadcast":{"id":"158564638127323","title":"猫和老鼠最后一集","priority":0,"description":"testInsertBroastcast","type":null,"path":"http://125.62.47.82/upload/xxx.mp4","cover":"http://125.62.47.85:18080/file/M02/00/01/wKgBf16dX1SANb2AAABf1RPx5A8034.jpg","createTime":"2020-03-31 09:19:41","updateTime":"2020-03-31 09:19:41","columeId":"123"},"correlation":[{"id":"158564638127376","title":"猫和老鼠第三集","priority":0,"description":"testInsertBroastcast","type":null,"path":"http://125.62.47.82/upload/xxx.mp4","cover":"http://125.62.47.85:18080/file/M03/00/01/wKgBf16dX2KANY7cAAB65aVWCMo414.jpg","createTime":"2020-03-31 09:19:41","updateTime":"2020-03-31 09:19:41","columeId":"123"},{"id":"158626156163762","title":"猫和老鼠第一集","priority":null,"description":null,"type":null,"path":"http://125.62.47.82/upload/xxx.mp4","cover":"http://125.62.47.85:18080/file/M00/00/01/wKgBf16dX3SAK4ZoAAA1UwZyGmw311.jpg","createTime":"2020-04-07 12:12:42","updateTime":"2020-04-07 12:12:42","columeId":"123"},{"id":"234","title":"猫和老鼠第二集","priority":0,"description":"test2","type":null,"path":"http://125.62.47.82/upload/xxx.mp4","cover":"http://125.62.47.85:18080/file/M01/00/01/wKgBf16dX4WAAmLLAABbTesw2sg835.jpg","createTime":"2020-03-31 15:40:50","updateTime":"2020-03-31 15:40:51","columeId":"123"}]}}
     */
    @GetMapping("/broadcastDetailAndCorrelation")
    public BaseResult broadcastDetailAndCorrelation(String id) {
        if (StringUtils.isBlank(id)){
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return broadcastService.broadcastDetailAndCorrelation(id);
    }

    /**
     * showdoc
     * @catalog 社区/直播
     * @title 获取栏目类型
     * @method  get
     * @description  获取栏目类型
     * @url /cms/broadcast/getColumeType
     * @return {"status":200,"msg":"SUCCESS","data":[{"id":"158564818887714","name":"慢直播","createTime":1585676948000,"updateTime":1585676946000,"description":"慢直播"}]}
     */
    @RequestMapping("/getColumeType")
    public BaseResult getColumeType() {
        return broadcastService.getColumeType();
    }
    /**
     * showdoc
     * @catalog 社区/直播
     * @title 栏目详情
     * @method  get
     * @description  栏目详情
     * @url /cms/broadcast/detail
     * @param id 必须 String 栏目ID
     * @return {"status":200,"msg":"SUCCESS","data":null}
     */
    @RequestMapping("/detail")
    public BaseResult detail(String id){
        if (StringUtils.isBlank(id)){
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return broadcastService.detail(id);
    }
}
